import { setItem, removeItem, getItem } from '../../utils/storage'
function userReducer(state = getItem('user') || {}, action) {

    let preState = { ...state }
    switch (action.type) {
      case 'login':
        preState = action.data
        setItem('user', action.data)
        return preState;
      case 'logout':
        console.log('退出登录')
        removeItem('user')
        window.location.href = '/login'
        return preState;
      default:
        return state;
    }
  }

  export default userReducer